<?php

/**
 * @author Invisible Man
 * @copyright 2013
 */
 //Checking Admin
 require('../includes/admin_auth.php');
 //Require Config
 require('../config.php');
 //Set Encoding
 header("Content-Type: text/html;charset=utf-8");
 //Checking data input
if (isset($_GET['id'])) {
    $del_id = $_GET['id'];
    //Connect Database
    require('../includes/db_connect.php');
    //SQL Query
    $query_info = 'SELECT * FROM categories WHERE cate_id=' . $del_id;
    $data_info = mysql_query($query_info, $db_con);
    if (mysql_num_rows($data_info) == 0) {
        echo '
        <script type="text/javascript">
            alert("Dữ liệu này không còn tồn tại");
            window.location = "cate_list.php";
        </script>';
    }
    else {
        $query_info = 'DELETE FROM categories WHERE cate_id=' . $del_id;
        mysql_query($query_info, $db_con);    
        if (mysql_errno($db_con) != 0) {
            header("location: cate_list.php?error=".mysql_errno($db_con));
            exit();
        } else {
            header("location: cate_list.php");
            exit();
        }
       
    }
}
else {
    header("location: cate_list.php");
    exit();
}



?>